﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;
using System.Windows.Automation;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UIPaneTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldGetPane()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsNotNull(pane);
        }

        [TestMethod]
        public void ShouldGetAllPanes()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            List<UIPane> panes = window.UIPanes();
            Assert.AreEqual(7, panes.Count);
        }

        [TestMethod]
        public void ShouldGetCanMove()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsFalse(pane.CanMove);
        }

        [TestMethod]
        public void ShouldGetCanResize()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsFalse(pane.CanResize);
        }

        [TestMethod]
        public void ShouldGetCanRotate()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsFalse(pane.CanRotate);
        }

        [TestMethod]
        public void ShouldGetHorizontallyScrollable()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsFalse(pane.HorizontallyScrollable);
        }

        [TestMethod]
        public void ShouldGetHorizontalScrollPercent()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsTrue(double.IsNaN(pane.HorizontalScrollPercent));
        }

        [TestMethod]
        public void ShouldGetHorizontalViewSize()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsTrue(double.IsNaN(pane.HorizontalViewSize));
        }

        [TestMethod]
        public void ShouldGetVerticallyScrollable()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsFalse(pane.VerticallyScrollable);
        }

        [TestMethod]
        public void ShouldGetVerticalScrollPercent()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsTrue(double.IsNaN(pane.VerticalScrollPercent));
        }

        [TestMethod]
        public void ShouldGetVerticalViewSize()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var pane = window.UITab("@AutomationId='tabControl1'").UITabItem("@Name='Tab 1'").UIPane();
            Assert.IsTrue(double.IsNaN(pane.VerticalViewSize));
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}